﻿using System;
using System.Collections.Generic;
using System.Text;
using ITAP.ShprossesBuilder.Modelling.Components;

namespace ITAP.ShprossesBuilder.Manipulation
{
    public abstract class SerializedUndoRedo
    {
        protected ModelControl modelControl;
        protected ModelContainer undoModelContainer;
        protected ModelContainer redoModelContainer;

        public virtual bool Undo(ModelControl modelControl)
        {
            redoModelContainer = (ModelContainer)modelControl.ModelContainer.Clone();
            modelControl.ModelContainer = (ModelContainer)undoModelContainer.Clone();            
            return true;
        }

        public virtual bool Redo(ModelControl modelControl)
        {
            undoModelContainer = modelControl.ModelContainer;
            modelControl.ModelContainer = redoModelContainer;
            return true;
        }

        public virtual bool CanUndo 
        { 
            get { return true; } 
        }
    }
}
